import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '任务编码',
    align: "center",
    sorter: true,
    dataIndex: 'taskNo'
  },
  {
    title: '任务名称',
    align: "center",
    sorter: true,
    dataIndex: 'taskName'
  },
  {
    title: '需求条目数',
    align: "center",
    dataIndex: 'reqItemCount',
    width:100
  },
  {
    title: '正例数',
    align: "center",
    sorter: true,
    dataIndex: 'positiveCount',
    width:80
  },
  {
    title: '反例数',
    align: "center",
    sorter: true,
    dataIndex: 'negativeCount',
    width:80
  },
  {
    title: '生成状态',
    align: "center",
    dataIndex: 'genStatus',
    width:80,
    customRender: ({ text }) => {
      const color = 'red';
      if(text =='生成中') {
        return render.renderTag(text, 'green');
      } else if(text =='生成完成') {
        return render.renderTag(text, 'blue');
      }
    }
  },
  {
    title: '预计用例数',
    align: "center",
    dataIndex: 'expectCount',
    width:90
  },
  {
    title: '实际用例数',
    align: "center",
    dataIndex: 'successCount',
    width:90
  },
  {
    title: '生成成功率(%)',
    align: "center",
    dataIndex: 'genProcess',
    width:130
  },
  {
    title: '需求文档',
    align: "center",
    sorter: true,
    dataIndex: 'reqFile',
  },
  {
    title: '创建人',
    align: "center",
    sorter: true,
    dataIndex: 'createBy'
  },
  {
    title: '创建日期',
    align: "center",
    sorter: true,
    dataIndex: 'createTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "任务名称",
    field: 'taskName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "任务编码",
    field: 'taskNo',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "正例数量",
    field: 'positiveCount',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "反例数量",
    field: 'negativeCount',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "生成状态",
    field: 'genStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "gen_status"
    },
    //colProps: {span: 6},
  },
  {
    label: "生成进度",
    field: 'genProcess',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "需求文档",
    field: 'reqFile',
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '任务名称',
    field: 'taskName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入任务名称!'},
             ];
    },
  },
  {
    label: '正例数量',
    field: 'positiveCount',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入正例数量!'},
             ];
    },
  },
  {
    label: '反例数量',
    field: 'negativeCount',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入反例数量!'},
             ];
    },
  },
  {
    label: '需求文档',
    field: 'reqFile',
    component: 'JUpload',
    componentProps:{
     },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入需求文档!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  taskName: {title: '任务名称',order: 0,view: 'text', type: 'string',},
  taskNo: {title: '任务编码',order: 1,view: 'text', type: 'string',},
  positiveCount: {title: '正例数量',order: 2,view: 'number', type: 'number',},
  negativeCount: {title: '反例数量',order: 3,view: 'number', type: 'number',},
  genStatus: {title: '生成状态',order: 4,view: 'list', type: 'string',dictCode: 'gen_status',},
  genProcess: {title: '生成进度',order: 5,view: 'number', type: 'number',},
  reqFile: {title: '需求文档',order: 6,view: 'file', type: 'string',},
  createBy: {title: '创建人',order: 7,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 8,view: 'datetime', type: 'string',},
};
